;数据段
datas SEGMENT USE16
    
datas ENDS

;堆栈段
stacks SEGMENT USE16
    
stacks ENDS

;代码段
codes SEGMENT USE16
    assume cs:codes,ds:datas,ss:stacks
start:
    mov ax,datas
    mov ds,ax

    call gensound

    mov ah,4ch
    int 21h

;-----------------------------
;发声子程序
gensound PROC near
    push ax
    push bx
    push cx
    push dx
    push di
    mov al,0b6h
    out 43h,al
    mov dx,12h
    mov ax,348ch
    div di
    out 42h,al
    mov al,ah
    out 42h,al
    in al,61h
    mov ah,al
    or al,3
    out 61h,al
wait1:
    mov cx,2800
delay:
    loop delay
    dec bx
    jnz wait1
    mov al,ah
    out 61h,al
    pop di
    pop dx
    pop cx
    pop bx
    pop ax
    ret
gensound ENDP
codes ENDS
    end start